home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Review 28
/
Creative-Review-CD-ROM-28.iso
/
pc
/
kungfu
/
assets
/
game.dir
/
00022_Script_sound manager class
< prev
next >
Wrap
Text File
|
1997-08-08
|
6KB
|
293 lines
-- sound class
-- --------------------------------------------------
property q
property qflag
property streams
property moves
property slaps
property streampath
property channel
property updategap
property max
global gtime, gcallback
-- ==================================================
-- new method
-- --------------------------------------------------
on new me
minit me
return me
end mnew
-- ==================================================
-- minit method
-- --------------------------------------------------
on minit me
set moves = data2list ( "move sound compile data")
set slaps = data2list ( "slap sound compile data")
set streams = data2list ( "stream sound data" )
if the machinetype = 256 then
set platformseperator = "\"
else
set platformseperator = ":"
end if
set streampath = the moviepath & "audio" & platformseperator
set channel = 1
set q = []
set qflag = false
set updategap = 20
set max = 3
end minit
-- ==================================================
-- mmove method
-- --------------------------------------------------
on mmove me, who, move
-- put "in mmove sound manager", who, move
set wholist = getaprop ( moves, who )
set currentsound = getaprop ( wholist, move )
-- put "currentsound:" , currentsound
if stringp ( currentsound ) then
mplay me, currentsound
else if listp ( currentsound ) then
set chosensound = getat ( random ( count ( currentsound ) ) )
mplay me, chosensound
end if
-- put "out mmove sound manager" , currentsound
end mmove
-- ==================================================
-- mslap method
-- --------------------------------------------------
on mslap me, who
-- put "in mslap sound manager class :" , who
set wholist = getaprop ( slaps, who )
set currentsound = getaprop ( wholist, random ( count ( wholist ) ) )
if stringp ( currentsound ) then
mplay me, currentsound
end if
-- put "out mslap sound manager class :"
end mslap
-- ==================================================
-- mback method
-- --------------------------------------------------
on mback me, loop
put "in mback sound manager class :"
if the machinetype = 256 then
set the movierate of sprite 40 = 1
else
if stringp ( loop ) then
sound stop 3
puppetsound 3, loop
end if
end if
put "out mback sound manager class :"
end mback
-- ==================================================
-- mstopback method
-- --------------------------------------------------
on mstopback me
-- put "in mstopback sound manager"
if the machinetype = 256 then
set the movierate of sprite 40 = 0
else
sound stop 3
end if
-- put "out mstopback sound manager"
end mstopback
-- ==================================================
-- msoundbusy method
-- --------------------------------------------------
on msoundbusy me
-- put "in msoundbusy sound manager"
if qflag then return false
if soundbusy ( 1 ) then return true
if soundbusy ( 2 ) then return true
return false
-- put "out msoundbusy sound manager"
end msoundbusy
-- ==================================================
-- mstream method
-- --------------------------------------------------
on mstream me, data
-- put "in mstream sound manager class :", data
set currentsound = getaprop ( streams, data )
if not ( stringp ( currentsound ) ) then return
-- put streampath & currentsound
sound stop 1
sound stop 2
mstopback me
memptyq me
updatestage
if stringp ( currentsound ) then
sound playfile 2, streampath & currentsound
end if
-- put "out mstream sound manager class :"
end mstream
-- ==================================================
-- mstop method
-- --------------------------------------------------
on mstop me
sound stop 1
sound stop 2
sound stop 3
end mstop
-- ==================================================
-- mplay method
-- --------------------------------------------------
on mplay me, newsound
-- put "in mplay sound manager class :"
if qflag or soundbusy ( channel ) then
maddq ( me, newsound )
else
puppetsound ( channel, newsound )
end if
-- put "out mplay sound manager class :"
end mplay
-- ==================================================
-- maddq method
-- --------------------------------------------------
on maddq me, newsound
-- put "in maddq sound manager class :"
if not ( qflag ) then
set qflag = true
maddtask gtime, me, the timer
end if
add q, newsound
-- put "out maddq sound manager class :"
end maddq
-- ==================================================
-- mdotask method
-- --------------------------------------------------
on mdotask me
-- put "in mdotask sound manager class :"
if ( mcheckq ( me ) ) then return updategap
else return false
-- put "out mdotask sound manager class :"
end mdotask
-- ==================================================
-- memptyq method
-- --------------------------------------------------
on memptyq me
set q = []
set qflag = false
mdeletetasks gtime, me
return false
end mempty
-- ==================================================
-- mcheckq method
-- --------------------------------------------------
on mcheckq me
-- put "in mcheckq sound manager class :"
set newsound = getat ( q , 1 )
puppetsound channel, newsound
deleteat ( q, 1 )
if count ( q ) > max then set q = []
if not ( count ( q ) ) then
set qflag = false
mdeletetasks gtime, me
return false
end if
return true
-- put "out mcheckq sound manager class :"
end mcheckq